package springcloud.easybuy.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springcloud.easybuy.dao.EasybuyProductDao;
import springcloud.easybuy.entity.EasybuyProduct;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/product/provider")
@ResponseBody
public class EasybuyProductController {

    @Resource
    private EasybuyProductDao easybuyProductDao;

    @RequestMapping("/queryAllProduct")
    public List<EasybuyProduct> queryAllProduct(){
        return easybuyProductDao.findAll();
    }


    @RequestMapping("/findProductById/{id}")
    public List<EasybuyProduct> queryProductById(@PathVariable("id") int id){
        return easybuyProductDao.findByCategoryLevel1Id(id);
    }


    @RequestMapping("/findById/{id}")
    public EasybuyProduct findById(@PathVariable("id") int id){
        return  easybuyProductDao.findById(id);
    }
}
